var mysql = require('mysql');
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'test' 
});

// 2. 连接数据库
connection.connect();

// 3. 执行数据操作，查询表并打印
connection.query('SELECT * FROM `square_card`', function (error, results, fields) {
    if (error) throw error;
    // var data = results[0].user;

    var data = []
    exports.data = data;
    for(i=0; i<results.length; i++){
        data[i] = results[i]
    }
    
    // res.end(JSON.stringify(data))
    console.log(JSON.stringify(data))
    // console.log('The solution is: ', data);
    // console.log(results[0].id)
    // console.log(results[0].content_text)

            
});
// 4. 关闭连接
connection.end();